#define _CRT_SECURE_NO_WARNINGS 1
#include <list>
#include<stdio.h>

typedef struct list
{
    int num;
    list* next;
}list;

int main()
{
    int length = 0;
    int i = 0;
    list* l = NULL;
    list* p = NULL;

    scanf("%d", &length);
    l = p = new list;
    for (i = 0; i < length ; i++)
    {
        p->next = new list;
        p = p->next;
        scanf("%d", &p->num);
    }
    p->next = NULL;

    list* temp = NULL;
    p = l->next;
    temp = p->next;
    p->next = temp->next;
    temp->next = p;
    l->next = temp;

    for (i = 0, p = l; i < length - 2; i++)
    {
        p = p->next;
    }

    temp = p->next;
    p->next = temp->next;
    temp->next->next = temp;
    temp->next = NULL;

    
    for (p = l, i = 0; i < length; i++)
    {
        p = p->next;
        printf("%d ", p->num);
    }

    return 0;
}